﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="入库明细.aspx.cs" Inherits="syc.ZhiJian.Report.入库明细" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <script type="text/javascript" language="javascript" src="/common.js"></script>
    <script src="../jquery.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript" >
        
        //PAGE_LOAD()
        $(document).ready(function() {
                 //截止日期默认取当天
                    $('#Date1').change(function() {
                        if ($('#Date2').val() == "") {
                            $('#Date2').val($('#Date1').val());
                        }
                    });
                    //清空两个日期框
                    $('#clear').click(function() {
                        $('#Date1').val("");
                        $('#Date2').val("");
                    });
        });						
    </script>
</head>
<body>
    <form id="form1" runat="server">
  
   <div class="hooo">
        <div id="wintop" class="wintop"><span lang="zh-cn"><u>入库明细</u></span></div>
        <asp:Panel ID="Panel1" runat="server" CssClass="panel" Height="36px" Width="972px">
  
        <table>
        <tr id="row2" runat="server">
        <td>         
        <span style="width:220px;text-align:right;">
            起始日期：<asp:TextBox ID="Date1" runat="server" CssClass="intxt1" Width="120px" AutoPostBack="true"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" />
        </span>
        </td>
        
        <td>
        <span style="width:220px;text-align:right;">
            截止日期：<asp:TextBox ID="Date2" runat="server" CssClass="intxt1" Width="120px" AutoPostBack="true"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" />
        </span>
        <input type="button" class="smallbutton" id="clear" value="清空日期"/>
        </td>
       
        <td>
        &nbsp;&nbsp;产品:
        </td>
        <td>
        <asp:DropDownList ID="DList_Produce" runat="server" AutoPostBack="True" 
                onselectedindexchanged="DList_month_SelectedIndexChanged">
            <asp:ListItem Value="1">油管</asp:ListItem>
            <asp:ListItem Value="2">套管</asp:ListItem>
        </asp:DropDownList>
        </td>
        <td>
        &nbsp;&nbsp;分厂:
        </td>
       <td>
        <asp:DropDownList ID="DList_Fenchang" runat="server" AutoPostBack="True" 
               onselectedindexchanged="DList_Fenchang_SelectedIndexChanged" >
            <asp:ListItem Value="1">一</asp:ListItem>
            <asp:ListItem Value="2">二</asp:ListItem>
            <asp:ListItem Value="5">五</asp:ListItem>
        </asp:DropDownList>
        </td>
        <td id="shengchanxian" runat="server">
        &nbsp;&nbsp;生产线:<asp:DropDownList ID="DList_shengchanxian" runat="server" AutoPostBack="True" 
                onselectedindexchanged="DList_shengchanxian_SelectedIndexChanged">
            <asp:ListItem Value="0">全部</asp:ListItem>
            <asp:ListItem Value="1">一号线</asp:ListItem>
            <asp:ListItem Value="2">二号线</asp:ListItem>
            </asp:DropDownList>
        </td>
        <td>&nbsp;&nbsp;&nbsp;<asp:Button ID="Query" runat="server" CssClass="button" Text="生成报表" onclick="Query_Click" /></td>
        <td><asp:Button ID="Button1" runat="server" CssClass="button" Text="导出" onclick="Button1_Click" /></td>
        </tr>
        </table>

        </asp:Panel>
        <asp:Panel ID="Panel2" runat="server" CssClass="panel2" Width="962px">
        <asp:Label ID="Message" runat="server" Text="·准备就绪" CssClass="prompt" Visible="True"></asp:Label>
        </asp:Panel> 
    

        <div align="center" id="report"">    
                <h1 style="text-align: center;">
            <%=Date1.Text%>到<%=Date2.Text%><%=DList_Fenchang.SelectedItem.Text %>分厂<%=DList_Produce.SelectedItem.Text%>入库明细</h1>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataSourceID="SqlDataSource1" style="text-align: center" BorderColor="Black" 
                BorderStyle="Solid" BorderWidth="2px">
            <RowStyle Height="40px" />
            <Columns>
                <asp:BoundField DataField="名称" HeaderText="名称" 
                    SortExpression="名称" ItemStyle-CssClass="供货单位" >
                </asp:BoundField>
                <asp:BoundField DataField="入库日期" HeaderText="入库日期" 
                    SortExpression="入库日期" DataFormatString="{0:d}" ItemStyle-Width="100" />
                <asp:BoundField DataField="捆数" HeaderText="捆数" 
                    SortExpression="捆数" ReadOnly="True" ItemStyle-Width="50">
                </asp:BoundField>
                <asp:BoundField DataField="支数" HeaderText="支数" 
                    SortExpression="支数" ReadOnly="True" ItemStyle-Width="50">
                </asp:BoundField>
                <asp:BoundField DataField="重量" HeaderText="重量" 
                    SortExpression="重量" ReadOnly="True" ItemStyle-Width="80">
                </asp:BoundField>
                <asp:BoundField DataField="长度" HeaderText="长度" ReadOnly="True" 
                    SortExpression="长度" ItemStyle-Width="80">
                </asp:BoundField>
                <asp:BoundField DataField="炉号" HeaderText="炉号" ReadOnly="True" 
                    SortExpression="炉号" ItemStyle-Width="200" >
                </asp:BoundField>
                <asp:BoundField DataField="备注" HeaderText="备注" ReadOnly="True" 
                    SortExpression="备注" ItemStyle-Width="200"/>
            </Columns>
            <HeaderStyle Height="40px" />
        </asp:GridView>
        </div>
    
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
            SelectCommand="SELECT dbo.原料供货单位.名称, 
	   kc.入库日期,
	   COUNT(*) AS 捆数, 
	   SUM(kc.支数) AS 支数, 
	   SUM(kc.重量) AS 重量, 
	   SUM(kc.长度) AS 长度,
	   (SELECT distinct kc2.炉号+'' 
		FROM dbo.产品库存 as kc2 
	    WHERE (kc2.入库日期=kc.入库日期) AND
	          (kc2.产品类别ID = 2)  AND
              (kc2.生产单位ID = 1)
	    FOR XML PATH('')
	   ) AS 炉号,
	   (SELECT distinct RTRIM(kc3.捆号)+'为'+CAST([支数] AS varchar(4))+'支 '
		FROM dbo.产品库存 as kc3
	    WHERE (kc3.入库日期=kc.入库日期) AND
			  (kc3.支数!=7	) AND
			  (kc3.产品类别ID = 2) AND
              (kc3.生产单位ID = 1)
	    FOR XML PATH('')	    
	   ) AS 备注
FROM dbo.产品库存 AS kc INNER JOIN
     dbo.产品 ON kc.产品类别ID = dbo.产品.ID INNER JOIN
     dbo.原料供货单位 ON kc.原料供货ID = dbo.原料供货单位.ID
WHERE (kc.产品类别ID = 2) AND
      (kc.生产单位ID=1) AND
      (kc.状态!=0)
GROUP BY dbo.原料供货单位.名称, kc.入库日期"></asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>
